package simplevideochat.application.drawingdesk
{
	import flash.display.BitmapData;
	import flash.geom.Point;
	
	/**
	 * Класс для передачи данных по сети
	 * @author Alexey Ustinov
	 */
	public dynamic class DrawingDeskConnectionData extends Object 
	{
		
		static public const CLEAR_ALL_EVENT:String = "drawing_desk_clear_all_event";
		static public const DRAW_EVENT:String = "drawing_desk_draw_event";
		
		private var _type:String;
		private var _points:Vector.<Point>;
		private var _thickness:uint;
		private var _color:uint;
		
		public function DrawingDeskConnectionData(type:String="", points:Vector.<Point> = null, color:uint = 0, thickness:uint = 0) 
		{
			super();
			this.type = type;
			this.color = color;
			this.points = points;
			this.thickness = thickness;
		}
		
		static public function parseFromObject(object:Object):DrawingDeskConnectionData
		{
			if (object) {
				var data:DrawingDeskConnectionData = new DrawingDeskConnectionData();
			
				data.thickness = object.thickness;
				data.color = object.color;
				
				for each(var point:Object in object.points) {
					data.points.push(new Point(point.x, point.y));
				}
				
				return data;
			}
			
			return null;
		}
		
		public function get type():String 
		{
			return _type;
		}
		
		public function set type(value:String):void 
		{
			_type = value;
		}
		
		public function get thickness():uint 
		{
			return _thickness;
		}
		
		public function set thickness(value:uint):void 
		{
			_thickness = value;
		}
		
		public function get color():uint 
		{
			return _color;
		}
		
		public function set color(value:uint):void 
		{
			_color = value;
		}
		
		public function get points():Vector.<Point> 
		{
			return _points;
		}
		
		public function set points(value:Vector.<Point>):void 
		{
			_points = new Vector.<Point>();
			for each(var point:Point in value)
			{
				_points.push(point);
			}
		}
		
	}

}